<?php
require_once("init.php");
require_once("inc/header.php");

$id=$_GET['id'];
$page=$_GET['page'];
if(!intval($page)>0) {
    $page=1;
}
if(is_null($id)) {
    $url="http://api.twitter.com/1/".USER."/lists.json";
    $lists=get_from_twitter($url);
    if(!is_null($lists)){
        foreach($lists as $list) {
            if($list) {
                foreach($list as $item) {
                    $item=obj_to_array($item);
                    echo "<a href=\"list.php?id=".$item['id']."\">".$item['name']."</a><br />\n";
                }
            }
        }
    }
} else {

    $url="http://api.twitter.com/1/".USER."/lists/".$id."/statuses.json?page=".$page;
    $timeline=obj_to_array(get_from_twitter($url));
    $i=0;
    foreach($timeline as $msg) {
        $i+=1;
        show_msg($i,$msg,$type,$page);
    }
    if($page>1) {
        echo "<a href='list.php?id=".$id."&page=".($page-1)."'>prev</a> ";
    }
    echo "<a href='list.php?id=".$id."&page=".($page+1)."'>next</a> ";
}
require_once("inc/footer.php");
?>